package com.fast.develop.management.resource.schema;

import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import com.fast.develop.management.resource.utils.SchemaFileUtil;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 莫寅
 * @createTime 2022-06-16 22:37
 * @desc：
 */
public class DomainFieldInitializedDataHandler implements InitializedDataHandler{


    private static String templateJson;

    static {
        InputStream inputStream = DomainFieldInitializedDataHandler.class.getResourceAsStream("/meta/templates/domain_field_initialized_data.json");
        templateJson = IoUtil.readUtf8(inputStream);
    }

    @Override
    public String getData(String fullName){
        String fileName = SchemaFileUtil.getPathName(fullName);
        Map variable = new HashMap();
        variable.put("name", fileName);
        return StrUtil.format(templateJson, variable);
    }
}
